<?php
/**
 * utilBrowser
 *
 * 브라우저 정보를 받아옵니다.
 * <code>
 * $utilBrowser = new utilBrowser;
 * $utilBrowser->Name;
 * $utilBrowser->Version;
 * </code>
 *
 * @author 정상두
 * @package util
 *
 */
class utilBrowser
{
    private $aProps    = array("Version" => "0.0.0",
                              "Name" => "unknown",
                              "Agent" => "unknown");

    public function __construct()
    {
        $aBorwser = array("firefox", "msie", "opera", "chrome", "safari",
                            "mozilla", "seamonkey",    "konqueror", "netscape",
                            "gecko", "navigator", "mosaic", "lynx", "amaya",
                            "omniweb", "avant", "camino", "flock", "aol");

        $this->Agent = strtolower($_SERVER['HTTP_USER_AGENT']);
        foreach ($aBorwser as $sBorwser) {
            if (preg_match("#($sBorwser)[/ ]?([0-9.]*)#", $this->Agent, $aMatch)) {
                $this->Name = $aMatch[1];
                $this->Version = $aMatch[2];
                break ;
            }
        }
    }

    public function __get($sName)
    {
        return $this->aProps[$sName] ;
    }

    public function __set($sName, $sVal)
    {
        $this->aProps[$sName] = $sVal ;
    }
}